﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MachiningHelper.ToolFile
{
    public class RouteOptimize
    {
        #region 将铣透的铣型后移
        public static void CutOffRoute(MachiningPart part)
        {
            List<RouteSeq> fleetRoute = new List<RouteSeq>();
            List<RouteSeq> deepRoute = new List<RouteSeq>();
            bool isdeep;
            double thickness = double.Parse(part.Border.PanelThickness);
            foreach (var R in part.Routes)
            {
                isdeep = false;
                if(!(double.Parse( R.SetMillSeq.RouteSetMillZ)<thickness)||!(double.Parse( R.SetMillSeq.RouteZ)<thickness))
                {
                    deepRoute.Add(R);
                    continue;
                }
                foreach (var RP in R.RouteSeqs)
                {
                    if (!(double.Parse(RP.RouteZ) < thickness) || !(double.Parse(RP.RouteSetMillZ) < thickness))
                    {
                        deepRoute.Add(R);
                        isdeep = true;
                        break;
                    }
                }
                if(!isdeep)
                fleetRoute.Add(R);
                continue;
            }
            part.Routes.Clear();
            part.Routes.AddRange(fleetRoute);
            part.Routes.AddRange(deepRoute);
        }
        #endregion
    }
}
